﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace GameName1
{
    class XnaSpaceShipDecorator : XnaGameObjectDecorator
    {
        private SpaceShip _spaceShip;
        
        public XnaSpaceShipDecorator(SpaceShip spaceShip)
        {
            this._spaceShip = spaceShip;
        }


        public override Vector2 Velocity
        {
            get { return _spaceShip.Velocity; }
            set { _spaceShip.Velocity = value; }
        }

        public override Vector2 Position
        {
            get { return _spaceShip.Position; }
            set { _spaceShip.Position = value; }
        }

        public override void HandleHit()
        {
            _spaceShip.HandleHit();
        }

        public override void Move()
        {
            _spaceShip.Move();
        }

        public void ControlObject(KeyboardState keyState)
        {
            if (keyState.IsKeyDown(Keys.Left))
            {
                _spaceShip.Velocity = new Vector2(-6,0);
                Move();
            }


            if (keyState.IsKeyDown(Keys.Right))
            {
                _spaceShip.Velocity = new Vector2(6, 0);
                Move();
            }
                
            if (keyState.IsKeyDown(Keys.Space))
                _spaceShip.Fire();
        }
    }
}
